var util = require('../../utils/util.js');
var utilMd5 = require('../../utils/md5.js');
var app = getApp();
Page({
  data: {
    token: '',
    uid: 0,
    minHeight: 0,
    userinfo: {},
    username: []
  },
  onLoad: function (data) {
    var uid = data.uid;
    this.setData({
      uid: uid
    });
    var that = this;
    app.LoginUserInfo(function (res) {
      if(res && res != -1){
        that.setData({
          token: res.token
        });
      }
    });
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          minHeight: res.windowHeight
        });
      }
    });
    util.api({
      data: {
        "uid": uid,
        "publickey": util.publiccode,
        "ac": "userinfo"
      },
      success: function (responseData) {
        var tmpname = responseData.data.nickname + '的云名片';
        var tmpnamearr = [];
        for (var i = 0; i < tmpname.length; i++) {
          tmpnamearr[i] = tmpname[i];
        }
        that.setData({
          userinfo: responseData.data,
          username: tmpname
        });
      }
    });
  },
  goAtherPage: function (e) {
    var url = e.currentTarget.dataset.link;
    wx.navigateTo({ url: url })
  },
  goAtherPageRedirect: function (e) {
    var url = e.currentTarget.dataset.link;
    wx.redirectTo({ url: url })
  }
})